#!/bin/sh

## run mlterm, if there is a running mlterm
## connect to it via its socket
## %_loc: _home_/bin %

## $Id: mlterm.sh 11 2007-10-06 03:09:03Z dhg $

MLTERM_UID=`id -u`
MLTERM_SOCKET="/tmp/.mlterm-${MLTERM_UID}.unix"

if [ -S ${MLTERM_SOCKET} ];  then
	MLTERM_CMD=mlclient
else
	MLTERM_CMD=mlterm
fi

${MLTERM_CMD} 2> /dev/null
retval=$?

if [ ${retval} -gt 0 ]; then
	rm -f ${MLTERM_SOCKET}
	exec mlterm
	exit 0
fi
